#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import os
sys.path.append('src')

from processors.docx_processor import DOCXProcessor

def extract_choice_content():
    """提取选择题文件内容"""
    
    file_path = 'data/原始数据---选择题.docx'
    print(f'文件路径: {file_path}')
    print(f'文件存在: {os.path.exists(file_path)}')
    
    if not os.path.exists(file_path):
        print('文件不存在')
        return
    
    try:
        processor = DOCXProcessor()
        
        with open(file_path, 'rb') as f:
            file_content = f.read()
        
        result = processor.extract_content(file_content)
        
        print('\n=== 文件内容 ===')
        print(result['text'][:3000])  # 显示前3000个字符
        print(f'\n=== 文件信息 ===')
        print(f'文件总长度: {len(result["text"])} 字符')
        
        # 分析文本结构
        text = result['text']
        lines = text.split('\n')
        print(f'总行数: {len(lines)}')
        
        # 查找可能的题目分隔符
        print('\n=== 前20行内容 ===')
        for i, line in enumerate(lines[:20]):
            if line.strip():
                print(f'{i+1:2d}: {line.strip()}')
        
    except Exception as e:
        print(f'处理文件时出错: {e}')
        import traceback
        traceback.print_exc()

if __name__ == '__main__':
    extract_choice_content()